<?php  
class commonDao extends Dao {  
      
    var $table_name ;  
    var $fields ; 

    public function __construct(){
        parent::__construct();

    } 
        
    /**
     * 获得列表数据
     * @param  integer $num    
     * @param  integer $offest 
     * @param  array   $field  
     * @param  string  $id_key 
     * @param  string  $sort   
     * @return array          
     */
    function getList($table_name, $field = array(), $num = 0, $id_key = 'id', $sort = 'DESC'){
        $num = intval($num);
        $offest = 0;
        if($num > 0){
            $nowPage = $_POST['pageNum']==false? 1:$_POST['pageNum'];
            $num = $_POST['numPerPage']==false? $num:$_POST['numPerPage'];
            $offest = ($nowPage - 1)* $num;
        }
       
        $result = $this->dao->db->get_all($table_name, $num, $offest, $field , $id_key , $sort);
        $result = array('result'=>$result[0], 
                'page'=>array('total'=>$result[1],'num'=>$num,'nowPage'=>$nowPage)
            );
        return $result;
    }
} 